package cate.game.admin.menu.pay;

import cate.common.table.pay.PayItemRow;
import cate.common.util.TimeTool;
import cp.solution.business.pay.PayRecordEntity;
import cate.game.GameBody;
import cate.game.admin.menu.MenuSetup;
import cate.game.pay.PayDeliverParam;
import cate.game.pay.msg.PayOrderBuildReq;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class PayMenu extends MenuSetup {

    public PayMenu(GameBody game) {
        super("支付");

        reg(game, "客户端构建支付订单", 2, "【参数1】：itemTid，【参数2】：num", (role, params) -> {
            if (params.size() != 2) {
                return;
            }
            PayOrderBuildReq req = new PayOrderBuildReq();
            req.itemTid = Integer.parseInt(params.get(0));
            req.num = Integer.parseInt(params.get(1));
            req.forGmH(game, role);
        });

        reg(game, "假充值648", 0, "假得一", (role, params) -> {
            PayRecordEntity entity = new PayRecordEntity();
            entity.platformOrderId = "test";
            entity.itemTid = 1006;
            entity.payCents = 64800;
            role.getPay().deliver(entity, PayDeliverParam.normal);
        });

        reg(game, "假充值指定项", 1, "输入支付项ID", (role, params) -> {
            if (params.size() != 1) {
                return;
            }
            int payId = Integer.parseInt(params.get(0));
            PayItemRow configRow = role.getGame().table.pay.item.get(payId);
            if (configRow == null) {
                return;
            }
            PayRecordEntity entity = new PayRecordEntity();
            entity.platformOrderId = "test_platform_order";
            entity.platformPayStatus = "test_status";
            entity.rawOrderId = "ababa";
            entity.itemTid = payId;
            entity.payCents = configRow.price;
            role.getPay().deliver(entity, PayDeliverParam.normal);
        });

        reg(game, "循环月基金专用调时间", 0, "通过修改创角时间达到调时间的作用，不可逆！不可逆！不可逆！", (role, params) -> {
            role.getStatus().createTime -= TimeTool.TimeCons.DAY;
            role.onDaySpan(false);
            log.info("[PayMenu] 小天才：" + role.getBase().name + " 修改了自己的创角时间！");
        });

        reg(
                game,
                "清空特权",
                0,
                "要添加的数量",
                (master, params) -> {
                    master.getPay().tradeMall.privilegeMall.removeAllPrivilege();
                    game.notice.message(master, "修改成功");
                }
        );
    }
}
